
package com.jf.cloud.search.feign;


import com.jf.cloud.api.dto.PurchaseOrderUpdateDTO;
import com.jf.cloud.api.feign.SearchPurchaseOrderFeignClient;
import com.jf.cloud.api.order.bo.EsPurchaseOrderBO;
import com.jf.cloud.api.vo.EsPageVO;
import com.jf.cloud.common.order.dto.PurchaseOrderSearchDTO;
import com.jf.cloud.common.order.vo.EsPurchaseOrderVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.search.constant.EsIndexEnum;
import com.jf.cloud.search.manager.PurchaseOrderSearchManager;
import com.jf.cloud.search.util.EsSearchUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Hidden;


/**
 * 订单搜索feign连接
 * @author zz
 * @date 2020/12/07
 */
@RestController
@Hidden
public class SearchPurchaseOrderFeignController implements SearchPurchaseOrderFeignClient {

    @Autowired
    private PurchaseOrderSearchManager purchaseOrderSearchManager;

    @Override
    public ServerResponseEntity<EsPageVO<EsPurchaseOrderVO>> pagePurchaseOrder(PurchaseOrderSearchDTO purchaseOrderSearchDTO) {
        return ServerResponseEntity.success(purchaseOrderSearchManager.pageSearchResult(purchaseOrderSearchDTO));
    }

    @Override
    public ServerResponseEntity updatePurchaseOrderStatus(PurchaseOrderUpdateDTO purchaseOrder) {
        EsPurchaseOrderBO esOrder = new EsPurchaseOrderBO();
        esOrder.setStatus(purchaseOrder.getStatus());
        EsSearchUtil.esUpdate(purchaseOrder.getPurchaseOrderId(), EsIndexEnum.PURCHASE_ORDER, esOrder);
        return ServerResponseEntity.success();
    }
}
